﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
    xmlns:viewmodel="clr-namespace:Moneyman.ViewModel;assembly=Moneyman.ViewModel"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:UX="clr-namespace:Moneyman.UX;assembly=Moneyman.UX"
    xmlns:Converters="clr-namespace:Moneyman.Converters;assembly=Moneyman.Converters"
    x:Class="Moneyman.Wallet.Views.TransactionsDailyView" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">
    
    <phone:PhoneApplicationPage.Resources>
        <Converters:ResourceKeyToPathdataConverter x:Key="ResourceKeyToPathdataConverter"/>
        <Style TargetType="ListBoxItem" x:Key="daily_transaction_liststyle">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <StackPanel Margin="0,12">
                            <Grid Margin="12,0,0,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>
                                <Path Data="{Binding Category.IconResourceKey, Converter={StaticResource ResourceKeyToPathdataConverter}}" 
                                                      Stretch="Uniform" Fill="{StaticResource PhoneForegroundBrush}" 
                                                      Width="24" Margin="0,0,0,0" 
                                                      RenderTransformOrigin="0.5,0.5">
                                    <Path.RenderTransform>
                                        <TransformGroup>
                                            <RotateTransform Angle="0" />
                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                        </TransformGroup>
                                    </Path.RenderTransform>
                                </Path>
                                <TextBlock Text="{Binding Path=Category.Name}" Style="{StaticResource PhoneTextTitle3Style}" Grid.Column="1"/>
                                <TextBlock Text="{Binding Path=Amount, StringFormat=\{0:C\}}" Style="{StaticResource PhoneTextTitle3Style}" Grid.Column="2"/>
                            </Grid>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Path=Time, StringFormat=\{0:HH:mm:ss\}}" Style="{StaticResource PhoneTextTitle3Style}" Grid.Column="1" Foreground="{StaticResource PhoneChromeBrush}"/>
                                <TextBlock Text="{Binding Path=Remark}" Style="{StaticResource PhoneTextTitle3Style}" Grid.Column="1" Foreground="{StaticResource PhoneChromeBrush}"/>
                            </StackPanel>
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush Stretch="{Binding GlobalSettings.ImageStretch}" ImageSource="{Binding GlobalSettings.BackgroundImageSource, Mode=OneWay}"/>
        </Grid.Background>
        
        <Grid.DataContext>
            <viewmodel:TransactionsDailyViewModel/>
        </Grid.DataContext>
        
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <controls:Pivot Title="{StaticResource IDS_APP_NAME}">
            <controls:PivotItem Header="{StaticResource IDS_COMMON_INCOME}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock Style="{StaticResource PhoneTextTitle3Style}" Text="{Binding DailyIncome,StringFormat=\{0:C\}}"/>
                    <ListBox ItemContainerStyle="{StaticResource daily_transaction_liststyle}" ItemsSource="{Binding Path=DailyIncomeCollection}" Grid.Row="1"/>
                </Grid>
                
            </controls:PivotItem>

            <controls:PivotItem Header="{StaticResource IDS_COMMON_EXPENSE}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock Style="{StaticResource PhoneTextTitle3Style}" Text="{Binding DailyExpense,StringFormat=\{0:C\}}"/>
                    <ListBox ItemContainerStyle="{StaticResource daily_transaction_liststyle}" ItemsSource="{Binding Path=DailyExpenseCollection}" Grid.Row="1"/>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>
        <Grid Grid.Row="1" Margin="24,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <UX:UXPathButton IconPath="{StaticResource PATH_ICON_ARROW_LEFT}" Command="{Binding Path=DecreaseDateCommand}" />
            <toolkit:DatePicker Grid.Column="1" Value="{Binding SelectedDate, Mode=TwoWay}"/>
            <UX:UXPathButton IconPath="{StaticResource PATH_ICON_ARROW_RIGHT}" Grid.Column="2" Command="{Binding Path=IncreaseDateCommand}" />
        </Grid>
    </Grid>
    
</phone:PhoneApplicationPage>